{% extends "base_generic.html" %}

{% block content %}
  <div class="container">
    <div class="row mb-4">
      <div class="col-md-12">
        <div class="card">
          <div class="card-header bg-primary text-white">
            <h2 class="mb-0">{{ author.last_name }}{% if author.first_name %}, {{ author.first_name }}{% endif %}</h2>
          </div>
          <div class="card-body">
            <div class="row">
              <div class="col-md-3">
                {% if author.profile_image %}
                  <img src="{{ author.profile_image.url }}" class="img-fluid rounded mb-3" alt="{{ author.last_name }}的照片">
                {% else %}
                  <div class="text-center p-4 bg-light rounded mb-3">
                    <i class="fas fa-user fa-4x text-muted"></i>
                    <p class="mt-2 text-muted">暂无照片</p>
                  </div>
                {% endif %}
              </div>
              <div class="col-md-9">
                <div class="row">
                  <div class="col-md-4">
                    <h5>基本信息</h5>
                    <p>
                      {% if author.date_of_birth %}出生: {{ author.date_of_birth }}{% endif %}
                      {% if author.date_of_death %}<br>逝世: {{ author.date_of_death }}{% endif %}
                      {% if author.nationality %}<br>国籍: {{ author.nationality }}{% endif %}
                    </p>
                  </div>
                  <div class="col-md-8">
                    <h5>作家简介</h5>
                    {% if author.bio %}
                      <p>{{ author.bio }}</p>
                    {% else %}
                      <p>暂无简介信息</p>
                    {% endif %}
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    
    <div class="row mb-4">
      <div class="col-md-12">
        <div class="card">
          <div class="card-header bg-light">
            <h3 class="mb-0">生平事迹</h3>
          </div>
          <div class="card-body">
            {% if author.biography %}
              <div class="biography">
                {{ author.biography|linebreaks }}
              </div>
            {% else %}
              <p class="text-muted">暂无详细生平信息</p>
            {% endif %}
          </div>
        </div>
      </div>
    </div>
    
    <div class="row">
      <div class="col-md-12">
        <h3>著作列表</h3>
        {% if author.books.all %}
          <div class="list-group">
            {% for book in author.books.all %}
              <div class="list-group-item book-list-item">
                <div class="d-flex w-100 justify-content-between">
                  <h5 class="mb-1">
                    <a href="{{ book.get_absolute_url }}">{{ book.title }}</a>
                  </h5>
                  <small>{{ book.publication_year }}</small>
                </div>
                {% if book.summary %}
                  <p class="mb-1">{{ book.summary|truncatewords:30 }}</p>
                {% endif %}
                <div>
                  {% if book.genre.all %}
                    {% for genre in book.genre.all %}
                      <span class="badge badge-primary">{{ genre }}</span>
                    {% endfor %}
                  {% endif %}
                </div>
              </div>
            {% endfor %}
          </div>
        {% else %}
          <p>该作者暂无著作信息</p>
        {% endif %}
      </div>
    </div>
  </div>
{% endblock %} 